/*
  学习目标：setState第二个参数
*/

import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };

  handleClick = () => {
    // this.setState语法永远都是异步的
    this.setState((preState) => {
      return {
        count: preState.count + 1,
      };
    });
    this.setState((preState) => {
      return {
        count: preState.count + 2,
      };
    });
    this.setState((preState) => {
      return {
        count: preState.count + 3,
      };
    });

    console.log('this.state.count  ----->  ', this.state.count); // ??
  };

  render() {
    console.log('render  ----->  ');
    return (
      <div>
        <h1>{this.state.count}</h1>
        <button onClick={this.handleClick}>点我</button>
      </div>
    );
  }
}
